<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <!-- 1. .stop修饰符的使用-->
    <!-- 调用event.stopPropagation() 方法阻止事件冒泡到父元素，阻止任何父事件处理程序被执行-->
    <h2>{{message}}</h2>
    <div @click="divClick">
        <button @click.stop="btnClick">按钮</button>
    </div>

    <!-- 2. .prevent修饰符的使用-->
    <!--  调用 event.preventDefault()方法阻止元素发生默认的行为-->
    <form action="baidu">
        <input type="submit" value="提交" @click.prevent="submitClick">
    </form>

    <!--  3. .监听某个键盘的键帽-->
    <input type="text" @keyup.enter="keyUp">

    <!-- 4. .once修饰符的使用-->
    <!-- 只触发一次回调-->
    <button @click.once="btn2Click">按钮2</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            message: 'simplelu'
        },
        methods: {
            btnClick() {
                console.log('btnClick');
            },
            divClick() {
                console.log('divClick');
            },
            submitClick() {
                console.log('submitClick');
            },
            keyUp() {
                console.log('keyUp');
            },
            btn2Click() {
                console.log('btn2Click');
            }
        }
    })
</script>
</body>
</html>